cmake_minimum_required(VERSION 3.10.2)
project(preferences)

set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_FLAGS "-std=c++1y -fno-rtti -fvisibility=default -D_GNU_SOURCE")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fdata-sections -fPIC -fpic -ffunction-sections -D_GLIBC_MOCK")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wl,--no-as-needed -ldl")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wformat=0")

set(MOCK_DIR ${CMAKE_CURRENT_SOURCE_DIR}/../mock)
add_definitions(-DNAPI_EXPERIMENTAL)
aux_source_directory(${CMAKE_CURRENT_SOURCE_DIR}/frameworks/native/src preferences_src)
aux_source_directory(${CMAKE_CURRENT_SOURCE_DIR}/frameworks/js/napi/src preferences_src)
aux_source_directory(${CMAKE_CURRENT_SOURCE_DIR}/frameworks/js/common/src preferences_src)
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/frameworks/native/include)
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/frameworks/js/common/include)
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/frameworks/js/napi/include)
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/interfaces/inner_api/include)
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/../utils_native/base/include)
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/../utils_native/safwk/native/include)

FIND_PACKAGE(LibXml2)
IF (LibXml2_FOUND)
    include_directories(${LIBXML2_INCLUDE_DIR})
    MESSAGE(INFO, ${LIBXML2_INCLUDE_DIR})
ELSE (LibXml2_FOUND)
    MESSAGE(FATAL_ERROR, "libxml2_FOUND not found ${LibXml2_INCLUDE_DIR}")
ENDIF (LibXml2_FOUND)

include_directories(${CMAKE_INCLUDE_PATH}/libxml2)
include(${MOCK_DIR}/include/CMakeLists.txt OPTIONAL)

set(links secure mock relational_store xml2)
add_library(preferences SHARED ${preferences_src})
target_link_libraries(preferences ${links})